
# class CamelCaseUtil:
#     """
#     下划线形式(snake_case)转小驼峰形式(camelCase)工具方法
#     """

#     @classmethod
#     def snake_to_camel(cls, snake_str: str):
#         """
#         下划线形式字符串(snake_case)转换为小驼峰形式字符串(camelCase)

#         :param snake_str: 下划线形式字符串
#         :return: 小驼峰形式字符串
#         """
#         # 分割字符串
#         words = snake_str.split('_')
#         # 小驼峰命名，第一个词首字母小写，其余词首字母大写
#         return words[0] + ''.join(word.capitalize() for word in words[1:])

#     @classmethod
#     def transform_result(cls, result: Any):
#         """
#         针对不同类型将下划线形式(snake_case)批量转换为小驼峰形式(camelCase)方法

#         :param result: 输入数据
#         :return: 小驼峰形式结果
#         """
#         return SqlalchemyUtil.serialize_result(result=result, transform_case='snake_to_camel')

# class SnakeCaseUtil:
#     """
#     小驼峰形式(camelCase)转下划线形式(snake_case)工具方法
#     """

#     @classmethod
#     def camel_to_snake(cls, camel_str: str):
#         """
#         小驼峰形式字符串(camelCase)转换为下划线形式字符串(snake_case)

#         :param camel_str: 小驼峰形式字符串
#         :return: 下划线形式字符串
#         """
#         # 在大写字母前添加一个下划线，然后将整个字符串转为小写
#         words = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camel_str)
#         return re.sub('([a-z0-9])([A-Z])', r'\1_\2', words).lower()

#     @classmethod
#     def transform_result(cls, result: Any):
#         """
#         针对不同类型将下划线形式(snake_case)批量转换为小驼峰形式(camelCase)方法

#         :param result: 输入数据
#         :return: 小驼峰形式结果
#         """
#         return SqlalchemyUtil.serialize_result(result=result, transform_case='camel_to_snake')

def bytes_to_human(n: float) -> str:
    """将字节大小格式化为易读字符串，如 15.92 GB"""
    symbols = ("B", "KB", "MB", "GB", "TB", "PB")
    prefix = {}
    for i, s in enumerate(symbols[1:], 1):
        prefix[s] = 1 << (i * 10)
    for s in reversed(symbols[1:]):
        if n >= prefix[s]:
            value = float(n) / prefix[s]
            return f"{value:.2f} {s}"
    return f"{n:.0f} B"